package com.aaa.proxy;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/6/14 15:10
 * @description：
 * @modified By：
 * @version:
 */
public class Test {
    public static void main(String[] args) {
       /* PhoneService phoneService= new PhoneServiceImpl();
        phoneService.buyPhone(200);*/

       /* PhoneService phoneService= new ProxyStaticInterface();
        phoneService.buyPhone(300);*/
      /*  PhoneServiceImpl proxyStaticExtends = new ProxyStaticExtends();
        proxyStaticExtends.buyPhone(400);*/
/*      //创建目标对象
      PhoneService phoneService= new PhoneServiceImpl();
      //创建代理对象
        MyDynamicProxyInterface myDynamicProxyInterface= new MyDynamicProxyInterface();
        PhoneService proxyObj = (PhoneService) myDynamicProxyInterface.getProxyObj(phoneService);
        //用谁执行？用代理对象
        proxyObj.buyPhone(290);*/

        //创建目标对象
       /* ComputerServiceImpl computerService = new ComputerServiceImpl();
        //创建代理对象
        MyDynamicProxyInterface myDynamicProxyInterface= new MyDynamicProxyInterface();
        ComputerServiceImpl proxyObj = (ComputerServiceImpl) myDynamicProxyInterface.getProxyObj(computerService);
        proxyObj.buyComputer(800);*/

        //cglib动态代理
        //创建代理对象
        ProxyDynamicCGlib proxyDynamicCGlib= new ProxyDynamicCGlib();
        ComputerServiceImpl proxyObj = (ComputerServiceImpl) proxyDynamicCGlib.getProxyObj(ComputerServiceImpl.class);
        proxyObj.buyComputer(300);
    }
}
